<?php
    require '../model/topicDao.php';
    if($_SERVER['REQUEST_METHOD']==='POST'){
        $title=trim($_POST['title']);
        $content=trim($_POST['content']);
        $userid=trim($_POST['userid']);
        $boardid=trim($_POST['boardid']);
        $result=add_topic($title,$content,$userid,$boardid);
        if($result){
            header('location:../views/index.php');
        }else{
            echo "Error: Failed to add topic.";
        }
    }else{
        header('location:../index.php');
    }
?>